package com.koron.css2.clientCenter.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.clientCenter.bean.ContractBean;
import com.koron.css2.clientCenter.mapper.UserInfoMapper;
import com.koron.css2.clientCenter.queryBean.ContractQueryBean;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.util.Constant;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;


/**
 * @author cd 供水合同查询
 */
public class WaterSupplyContractQuery implements ServerInterface {
    @Override
    public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
        try {
            ContractQueryBean bean = JsonUtils.objectToPojo(req.getData(), ContractQueryBean.class);
            UserInfoMapper mapper = factory.getMapper(UserInfoMapper.class);
            ContractBean contractBean = mapper.queryContractBean(bean.getUserNo());
            @SuppressWarnings("rawtypes")
            MessageBean<ContractBean> info = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "查询成功", ContractBean.class);
            info.setData(contractBean);
            return info;
        } catch (Exception e) {
            logger.error("转办人员列表查询" + e.getMessage(), e);
            return MessageBean.create(Constant.MESSAGE_INT_FAIL, "转办人员列表查询失败", null);
        }
    }
}